package tgc.edu.yzy.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;


public class JDBC {
	private static String a1="com.mysql.jdbc.Driver";
	private static String a2="jdbc:mysql://localhost:3306/pb";
	private static String a3="root";
	private static String a4="root";
	
	/***
	 * 中心服务器，绑定使用
	 */
	private static String fwqdk="jdbc:mysql://47.100.197.180:3306/xjpublic";
	private static String user="qqrobot";
	private static String name="936642284";
	/***
	 * 链接本地数据库，获取图片
	 * @return
	 */
	public static Connection ljsjk() {//链接数据库
		Connection connection=null;
		try {
			Class.forName(a1);//注册驱动
			connection =DriverManager.getConnection(a2,a3,a4);//建立链接
		}catch(Exception e) {
			System.out.println("数据库不存在，");
			return null;
		}
		return connection;
		
	}
	/***
	 * 中心服务器数据库
	 * @return
	 */
	public static Connection conn() {
		Connection connection=null;
		try {
			Class.forName(a1);//注册驱动
			connection =DriverManager.getConnection(fwqdk,user,name);//建立链接
		}catch(Exception e) {
			System.out.println("数据库不存在，");
			return null;
		}
		return connection;
	}
}
